import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import path from 'path'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    vueDevTools(),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), 'src/assets/svgs')],
      symbolId: 'icon-[dir]-[name]',
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  server: {
    proxy: {
      '/chat': {
        target: 'http://10.0.100.210/inf-app/a15078308594839552165916/chat', // 开发环境
        // target: 'http://10.0.101.40:18080/api', // 性能环境
        // target: 'http://10.0.101.44:18080/api', // 测试环境
        // target: 'http://10.0.100.45:18080/api', // 测试环境
        // target: 'http://10.0.101.115:18080/api', // 测试环境
        changeOrigin: true,
        rewrite: path => path.replace(/^\/chat/, ''),
      },
      '/api': {
        target: 'http://192.168.6.187:8081',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, ''),
      },
    },
  },
})
